import QtQuick 2.0

Item {
    id: name
    anchors.fill: parent

    property real startX: 0
    property real startY: 0

    function fly()
    {
        anim.restart()
    }

    MyInstance{
        id: love1
        source: "qrc:/love.png"
    }

    MyInstance{
        id: love2
        source: "qrc:/love1.png"
        width: 20
        fillMode: Image.PreserveAspectFit
    }

    MyInstance{
        id: love3
        source: "qrc:/love2.png"
    }

    ParallelAnimation{
        id: anim
        onStarted: {
            love1.opacity = 1
            love2.opacity = 1
            love3.opacity = 1
        }

        PropertyAnimation{target: love1; property:"x"; from: startX-love1.width/2; to: startX-love1.width/2 - 15 - getRandom(30); duration: 1000; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love1; property:"y"; from: startY-love1.height/2; to: startY-love1.height/2 - 15 - getRandom(30); duration: 1000; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love1; property:"opacity"; from: 1; to: 0; duration: 1000; }

        PropertyAnimation{target: love2; property:"x"; from: startX-love1.width/2; to: startX-love1.width/2 + getRandom(5); duration: 100*15; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love2; property:"y"; from: startY-love1.height/2; to: startY-love1.height/2 - 40 - getRandom(40); duration: 100*15; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love2; property:"opacity"; from: 1; to: 0; duration: 1000; }

        PropertyAnimation{target: love3; property:"x"; from: startX-love1.width/2; to: startX-love1.width/2 + 20 + getRandom(10); duration: 100*15; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love3; property:"y"; from: startY-love1.height/2; to: startY-love1.height/2 - 10 - getRandom(30); duration: 100*15; easing.type: Easing.OutCirc; }
        PropertyAnimation{target: love3; property:"opacity"; from: 1; to: 0; duration: 1000; }

        onStopped: {
            _OBJS_POOL.push(name)
        }
    }
}
